package com.liangwj.springbootweb.controller;

import com.liangwj.springbootweb.exceptionHandle.MyException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * TODO: Thymeleaf的controller
 * @author Liangwenjun
 * @date 2018-12-11
 * @version 1.0
 */
@Controller
@RequestMapping(value = "/hello")
public class ThymeleafController {

    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public String index(ModelMap modelMap) {
        modelMap.addAttribute("host", "http:www.baidu.com");
        return "index";
    }

    @RequestMapping(value = "/error", method = RequestMethod.GET)
    public String indexException(ModelMap modelMap) throws Exception {
        throw new Exception("error");
    }

    @RequestMapping(value = "/json", method = RequestMethod.GET)
    public String json() {
        throw new MyException("error json");
    }
}
